package com.community.mapper;

import com.community.pojo.ElderlyHealth;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserElderlyHealthMapper {
    @Select("select health_id as healthId,user_id as userId,height,age,weight,health_condition as healthCondition from elderly_health where user_id=#{userId}")
    ElderlyHealth findUserHealthInformation(Integer userId);

    @Update("update elderly_health set height=#{height},age=#{age},weight=#{weight},health_condition=#{healthCondition} where user_id=#{userId}")
    int updateUserHealthInofrmation(ElderlyHealth elderlyHealth);

    @Insert("insert into elderly_health(user_id,height,age,weight,health_condition)values (#{userId},#{height},#{age},#{height},#{healthCondition})")
    @Options(useGeneratedKeys = true,keyProperty = "healthId")
    int insertUserHealthInformation(ElderlyHealth elderlyHealth);
}
